# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Spyros Stathopoulos <foucault.online@gmail.com>
# Contributor: richli <rich at dranek dot com>
# Contributor: rememberthemer <rememberthemer@_GMAIL_DOT_COM_>

_pkg=netCDF4
pkgname=python-${_pkg,,}
pkgver=1.6.3
pkgrel=2
pkgdesc="Python/NumPy interface to the netCDF C library"
arch=(loong64 x86_64)
url="https://unidata.github.io/netcdf4-python"
license=(MIT)
depends=(python-numpy python-cftime netcdf)
makedepends=(cython python-setuptools)
source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
sha256sums=('8c98a3a8cda06920ee8bd24a71226ddf0328c22bd838b0afca9cb45fb4580d99')

build() {
  cd ${_pkg}-${pkgver}
  USE_NCCONFIG=1 python setup.py build
}

check() {
  cd ${_pkg}-${pkgver}/test
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  NO_NET=1 PYTHONPATH="../build/lib.linux-${CARCH}-cpython-${python_version/./}" python -B ./run_all.py
}

package() {
  cd ${_pkg}-${pkgver}
  USE_NCCONFIG=1 python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=2
  install -Dm644 LICENSE -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
